<!--
    group: 发票管理
    name: 发票记录 (开票详情与重开票详情)
    url: /invoice/invoiceRecord
-->
<template>
  <div class="main_content">
    <!--开票失败-->
    <div v-if="detailsData.bizStatus == 120" class="invoiceFail">
      <h4 class="red" style="font-weight: bolder;">开票失败！</h4>
      <!--errorFlag 1 无错误 2 开票人错误 3 其他错误-->
      <div v-if="detailsData.errorFlag == 2" class="invoiceFailItem">
        <a-alert message="开票员核验失效，请尽快要求开票员完成核验！" type="error" />
        <p>
          开票员：{{ detailsData.invoiceUser ? detailsData.invoiceUser : '代办开票' }}，
          {{{1:'企业法人',2:'内部员工',3:'渠道开票员'}[detailsData.invoiceUserType] || ''}}</p>
        <div class="invoiceFailFooter">
          <a-button @click="reInviteVerification" type="primary" :disabled="CountDownConfig.isRun" v-preventReClick>{{CountDownConfig.label}}</a-button>
          <!-- CountDownConfig.isRun v-if="showConfirmLogged"-->
          <a-button @click="confirmLogged" type="primary" class="mLeft" v-preventReClick>确认已核验</a-button>
          <a-button @click="changeInvoiceUser" type="primary" class="mLeft">变更开票员</a-button>
        </div>
      </div>

      <div v-if="detailsData.errorFlag == 3" class="invoiceFailItem">
        <a-alert v-if="detailsData.errorReason" :message="detailsData.errorReason" type="error" />
        <div class="invoiceFailFooter">
          <a-button @click="invoiceApplication" type="primary">变更开票申请</a-button>
          <a-button @click="revokeInvoice" type="danger" class="mLeft">撤销开票</a-button>
        </div>
      </div>

    </div>

    <!--发票信息内容-->
    <div>
      <h3><span class="icons"></span>发票信息</h3>
      <div class="information_content" v-if="detailsData">
        <!-- 发票公共详情 kpzmbc_流水回单上传  kppzck_查看流水回单  ywsmsxz_查看业务说明书  bcclck_查看合同及补充材料  -->
        <InvoiceCommonDetails :vhas="['inr_inrec:click:kpzmbc','inr_inrec:click:kppzck','inr_inrec:click:ywsmsxz','inr_inrec:click:bcclck']" :detailsData="detailsData" :invoiceType="'开票'" @handleUseFather="handleUseFather" />

        <detail-list v-if="detailsData.money && detailsData.billSegment && detailsData.ticketType == 1" title="发票领用" :col="2" class="detail-layout">
          <detail-list-item term="增值税专用发票领用数量（纸质）：">
            <span>{{ detailsData.billSegment.zz }} 张</span>
          </detail-list-item>
          <detail-list-item term="增值税普通发票领用数量（纸质）：">
            <span>{{ detailsData.billSegment.pz }} 张</span>
          </detail-list-item>
          <detail-list-item term="增值税专用发票领用数量（电子）：">
            <span>{{ detailsData.billSegment.zd }} 张</span>
          </detail-list-item>
          <detail-list-item term="增值税普通发票领用数量（电子）：">
            <span>{{ detailsData.billSegment.pd }} 张</span>
          </detail-list-item>
          <a-divider />
        </detail-list>
      </div>
    </div>

    <!-- 进度条 -->
    <h3><span class="icons"></span>开票进度</h3>
    <div class="information_footer">
      <!--
         步骤条状态   finish 完成   process 进行中   error 失败   wait 等待
         设置状态 setNodeStatus  0-未提交 1-完成 2-处理中 3-失败或拒绝
         操作方式 opDis  0-无 1-显示邀请核验接口 2-显示立即支付按钮  4-显示撤销法人核验 5-结算
         节点类型 setNodeType
                开票:    1-提交开票信息 2-发票审核 3-法人核验 4-等待支付 5-开具发票 6-开票完成 7-待结算
                退票:    21-提交开票信息 22-订单审核 23-法人核验 24-订单支付 25-退票 26-已完成
                重开票:  31-提交开票信息 32-发票审核 33-法人核验 34-等待支付 35-开具发票 36-开票完成
      -->
      <a-steps labelPlacement="vertical">
        <a-step :key="'step-'+index" v-for="(jery,index) in progressList"
                :status="
                        jery.setNodeStatus == 1 ? 'finish' :
                        jery.setNodeStatus == 2 ? 'process' :
                        jery.setNodeStatus == 3 ? 'error' : 'wait'"
        >
          <template v-for="item in colorList">
            <a-icon  slot="icon"
                     :style="jery.setNodeStatus == item.key ? 'color:' + item.colorType : 'color: #999999'"
                     v-if="jery.setNodeStatus == item.key" :key="item.key"
                     :type="item.type" theme="filled" :two-tone-color="item.colorType" />
          </template>
          <template slot="title">
            <span
              :style="jery.setNodeStatus == 0 ? 'color:#999999' :
                       jery.setNodeStatus == 1 ? 'color:#4266E5' :
                       jery.setNodeStatus == 2 ? 'color:#FF9B46' :
                       jery.setNodeStatus == 3 ? 'color:#FF6A6A' : 'color: #999999' "
            >{{ jery.setNodeName }}</span>
          </template>
          <span slot="description">
              <span v-if="(jery.setNodeType == 2 || jery.setNodeType == 32) && jery.setNodeStatus == 2">约2-3个工作日</span>
              <span v-if="(jery.setNodeType == 5 || jery.setNodeType == 35) && jery.setNodeStatus == 2">约1-3个工作日</span>
              <span v-if="(jery.setNodeType == 2 || jery.setNodeType == 32) && jery.errMsg"><br>{{ jery.errMsg }}</span>
              <a-button
                v-has="'inr_inrec:click:frhy'"
                v-if="(jery.setNodeType == 3 || jery.setNodeType == 23 || jery.setNodeType == 33) && jery.opDis == 1"
                @click="invitationValidationNew(jery)" class="line"
              >法人核验</a-button>
            <a-button v-has="'inr_inrec:click:js'"
              v-if="jery.setNodeType == 7 && jery.opDis == 5"
              @click="singleBalance" class="line">结算</a-button>
            <a-button v-has="'inr_inrec:click:cxhy'"
              v-if="jery.setNodeType == 3 && jery.opDis == 4"
              @click="revokeEvent" class="line">撤销核验</a-button>
              <a-button
                v-has="'inr_inrec:click:ljzf'"
                v-if="(jery.setNodeType == 4 || jery.setNodeType == 24 || jery.setNodeType == 34) && jery.opDis == 2 && jery.setNodeStatus == 2"
                @click="paymentOther(detailsData.payOrder)" class="line"
              >立即支付</a-button>
            <!--  taxMedium  1 纸质 显示快递单号  && jery.thirdOrder 2 电子  显示下载按钮  && detailsData.invoiceUrl  -->
              <span v-if="jery.setNodeType == 6 || jery.setNodeType == 36">
                <span
                  v-if="detailsData.taxMedium == 1 && jery.setNodeStatus == 1"
                >快递单号： {{ jery.thirdOrder }}</span>
                <a-button
                  v-has="'inr_inrec:click:xzfp'"
                  v-if="detailsData.taxMedium == 2 && jery.setNodeStatus == 1"
                  @click="invoiceDownload" class="line"
                >下载发票</a-button>
              </span>
            </span>
        </a-step>
      </a-steps>
    </div>

    <!--开票进度  status 1 新开票 2 退票 3 退票-错票-->
    <div class="preview">
      <p>
        <span v-if="detailsData.invoiceUrl">发票预览</span>
        <span v-if="(detailsData.bizStatus == 107 || detailsData.bizStatus == 307) && detailsData.taxMedium == 1">，确认发票内容无误后，点击
          <a-button v-has="'inr_inrec:click:kdkd'" @click="confirmDelivery" class="line">快递</a-button>，我们将为您安排快递
        </span>
      </p>
      <!--发票展示-->
      <div v-if="detailsData.invoiceUrl">
        <!--图片-->
        <div class="img_preview" v-if="isInvoiceType">
          <img :src="detailsData.invoiceUrl" alt="发票预览" :preview="0">
          <!--发票作废标识-->
          <a-button v-if="isInvoice && isVisable" class="voidInvoice">发票作废</a-button>
        </div>
        <!--文件-->
        <div class="text_preview" v-if="!isInvoiceType">
          <span @click="download(detailsData.invoice)">
            <j-ellipsis :value="detailsData.invoice.length > 0 ? detailsData.invoice[0].fileName : ''" :length="20" style="cursor: pointer" />
          </span>
          <a v-if="detailsData.invoiceUrl" :href="detailsData.invoiceUrl">下载查看</a>
          <!--发票作废标识-->
          <a-button v-has="'inr_inrec:click:fpzf'" v-if="isInvoice && isVisable" class="voidText" type="link">发票作废</a-button>
        </div>
      </div>
      <!--申请退票与查看退票详情-->
      <div class="footer">
<!--        <p v-if="detailsData.bizStatus >= 107 && detailsData.bizStatus <= 110">-->
<!--          <a-button class="line" @click="applyReopen">申请重开</a-button>-->
<!--        </p>-->
        <!--区分展示申请退票和退票查看  是否存在未完成的部分退票 true 存在 false 不存在 -->
        <p v-if="
              (detailsData.existsNoFinishReturnTax == false || detailsData.existsNoFinishReturnTax == null) && (
                (detailsData.bizStatus >= 107 && detailsData.bizStatus <= 110) ||
                (detailsData.bizStatus >= 307 && detailsData.bizStatus <= 310)
              )">
          <a-button v-has="'inr_inrec:click:sqzfch'" class="line" @click="applyRefund">申请作废/冲红</a-button>
          如果您对开票内容有疑问，请联系客服！
        </p>
        <p v-if="detailsData.existsNoFinishReturnTax">有进行中的退票业务，点击
          <a @click="seeReturnTicket">查看作废/冲红详情</a>
        </p>
      </div>
    </div>

    <!--操作记录-->
    <div v-if="detailsData.id" style="width: 100%;margin-top: 30px;">
      <a-divider />
      <auditProcess :bizId="detailsData.id" :flowCode="flowCode"></auditProcess>
    </div>


    <!-------------------- 结算    start ↓ --------------->
    <!-- 预估费用弹层（单笔和批量结算）1、无待支付订单 && 未跨阶梯 -->
    <InvoiceBalance :config="balanceConfig" :checkList="balanceCheckList" @balanceMethod="balanceMethod" />
    <!-- 有待支付订单选择弹层（单笔和批量结算）1、有待支付订单 && 未跨阶梯  2、有待支付订单 && 跨阶梯 -->
    <SettlementRemainPaid :config="bePaidConfig" :checkList="balanceCheckList" :toBePaidList="toBePaidList" @toBePaidMethod="toBePaidMethod" />
    <!-- 展示超限额等超额判断弹层 1、无待支付订单 && 超限额 （单笔结算） -->
    <InvoiceCoverPrompt :config="promptConfig" @fatherPromptMethod="fatherPromptMethod" @fatherPreserveMethod="fatherPreserveMethod" />
    <!--  展示超限额等超额判断弹层 1、无待支付订单 && 超限额 （批量结算） 2、有待支付订单 && 超限额 （单笔和批量结算） -->
    <InvoiceBatchOverLimit :config="overLimitConfig" :overLimitCheckList="overLimitCheckList" :toBePaidList="toBePaidList" @overLimitMethod="overLimitMethod" />
    <!-- 确认费用弹层
        1、无待支付订单 && 跨阶梯2、无待支付订单 && 超限额（下一步确认费用）
        3、有待支付订单 && 跨阶梯4、有待支付订单 && 超限额（下一步确认费用）
    -->
    <InvoiceBatchSettlement :config="batchConfig" :checkList="balanceCheckList" @batchMethod="batchMethod" />
    <!-- 变更征收方式弹层 -->
    <ChangeCollectionMethod v-if="entId" :entId="entId" :config="collectionConfig" @fatherBackMethod="fatherBackMethod" />
    <!-------------------- 结算与批量结算  end ↑ --------------->


    <!--邀请验证及二维码查看-->
    <InvitationCode
      :invitationShow="invitationShow"
      :inContent="detailsData"
      @handleCodeFather="handleCodeFather"
    />
    <invitationCodeNew :event="icnEvent" :rowData="invitationCodeNewData" :oldData="currentRowData" :show="invitationNewShow"></invitationCodeNew>
    <!-- 单组核验展示 -->
    <SingleDataVerification :dataType="dataType_" :event="icnEvent" :rowData="singleDataVerificationData" :show="singleInvitationNewShow"></SingleDataVerification>


    <!--查看快递,订单创建成功,订单创建失败-->
    <ModalCurrency :config="undoConfig" @fatherMethod="fatherMethod" />

    <!--申请退票-->
    <RefundTicketLayer
      :isRefundShow="refundFill"
      v-if="detailsData.id && detailsData.canReturnAmount"
      :ticketType="detailsData.ticketType"
      :billUseNum="detailsData.canReturnBillNum"
      :id="detailsData.id"
      :amount="detailsData.canReturnAmount"
      @handleFather="handleFather"
    />

    <!--下载发票-->
    <InvoiceDownloadFormat :config="downloadFormatInfo" />


    <!-------------------- 开票失败   start ↓ --------------->
    <!-- 重新邀请核验 -->
    <OpenModal v-bind="OpenModalConfig" :closeEvent="OpenModalCloseEvent"></OpenModal>
    <!-- 变更开票员弹层 -->
    <a-modal
      :footer="null"
      v-model="invoiceFailed.userStatus"
    >
      <!--选择开票员-->
      <h3>请选择新的开票员</h3>
      <a-select v-model="invoiceInfo.invoiceUserId" placeholder="请选择开票员" @change="handleChange" :showSearch="true" :allowClear="true" style="width: 100%;margin: 20px 0 10px 0;">
        <a-select-option v-for="(item,index) in invoicerNewList" :value="item.id" :info="item" :key="index">
          {{ item.name }}
        </a-select-option>
      </a-select>

      <div style="text-align: center;margin-top: 30px;">
        <a-button @click="userSure" type="primary" style="width: 120px;">确定</a-button>
      </div>
    </a-modal>
    <!-- 撤销开票弹层 -->
    <a-modal
      :width="750"
      size="middle"
      :footer="null"
      v-model="invoiceFailed.revokeStatus"
    >
      <h3>撤销开票申请</h3>
      <p style="margin-top: 10px;">撤销后，已支付费用将原路退回您的账户!</p>

      <h4>本次开票金额</h4>
      <a-table
        bordered
        :loading="revokeLoading"
        :columns="revokeColumns"
        :data-source="revokeData"
        :scroll="{y: 300}"
        :pagination="false"
      >
      </a-table>

      <template v-if="historyData.length > 0">
        <h4>本季度受影响发票订单</h4>
        <a-table
          bordered
          :loading="revokeLoading"
          :columns="historyColumns"
          :data-source="historyData"
          :scroll="{y: 300}"
          :pagination="false"
        >
        </a-table>
      </template>

      <div style="text-align: center;margin-top: 20px;">
        <a-button @click="revokeSure" type="primary">确认</a-button>
        <a-button @click="revokeCancle" type="default" class="mLeft">取消</a-button>
      </div>
    </a-modal>
    <!-- 正在开票中弹层提示 -->
    <a-modal
      v-model="invoiceFailed.invoicePendding"
      :title="null" :footer="null"
      :keyboard="false"
      :maskClosable="false"
      :closable="false"
      :centered="true"
    >
      <a-spin tip="正在开票中,请耐心等待..." size="large">
        <a-icon slot="indicator" type="loading" spin />
      </a-spin>
    </a-modal>
    <!-------------------- 开票失败  end ↑ --------------->
  </div>
</template>

<script>

import {
  getTaxInvoiceDetails, getInvoiceProgress, getConfirmDelivery,
  taxInvoiceCatalogById, turnFlowReceipt, findPayOrderRecord, taxSettleRevokedSMS,
  getEntSvConf, getEntQuarterAmount, getEntMoneyInfo, getSendList,
  queryTaxPayOrder, checkLimit, invoiceSettlement,
  getNotFinishedTicket, checkBatteryLimit, queryInvoiceManage,
  queryInvoiceUser, invoiceRevokeApplication, invoiceRevokeCostInfo,
  getInvoiceUserFaceState,queryConfirmedVerified,getEleIssuerAuth,
  getInvoiceWhetherUserFace,
} from '@/api/invoiceAdminister'
import { accAdd, accSub, conversionBranch, conversionElement, cloneObject, cutstr, } from '@/utils/util'
import * as Utils from '@/utils/util'
import InvoiceCommonDetails from '@/views/invoice/modules/invoiceCommonDetails'
import auditProcess from '@/views/common/auditProcess.vue'
import InvitationCode from '@views/invoice/verification/invitationCode.vue'
import invitationCodeNew from '@views/invoice/verification/invitationCodeNew.vue'
import SingleDataVerification from '@views/invoice/verification/SingleDataVerification.vue'
import ModalCurrency from "@views/invoice/common/modalCurrency.vue";
import RefundTicketLayer from '@views/invoice/common/refundTicketLayer'  //申请退票弹层
import InvoiceCoverPrompt from '@views/invoice/common/invoiceCoverPrompt.vue'
import ChangeCollectionMethod from '@views/invoice/common/changeCollectionMethod.vue'
import InvoiceBatchSettlement from '@views/invoice/balance/invoiceBatchSettlement.vue'
import InvoiceBalance from '@views/invoice/balance/invoiceBalance.vue'
import SettlementRemainPaid from '@views/invoice/balance/settlementRemainPaid.vue'
import InvoiceBatchOverLimit from '@views/invoice/balance/invoiceBatchOverLimit.vue'
import InvoiceDownloadFormat from '@views/invoice/common/invoiceDownloadFormat.vue'
import useCountDown from './components/utils/useCountDown'
import OpenModal from './components/OpenModal.vue'
import DetailList from '@/components/tools/DetailList'
const DetailListItem = DetailList.Item
export default {
  name: "invoiceRecord",
  inject: ['reload'],
  components:{
    OpenModal,
    InvoiceCommonDetails,
    ChangeCollectionMethod,
    InvoiceBatchOverLimit,
    InvoiceCoverPrompt,
    SettlementRemainPaid,
    InvoiceBalance,
    InvoiceBatchSettlement,
    ModalCurrency,
    auditProcess,
    RefundTicketLayer,
    InvitationCode,
    invitationCodeNew,
    SingleDataVerification,
    InvoiceDownloadFormat,
    DetailList,
    DetailListItem,
  },
  data(){
    return{
      flowCode: '20000001',
      id: null,  //开票id
      //获取详情和发票费用信息
      detailsData: {},

      //开票进度条
      progressList: [],
      colorList:[
        {
          key:0,
          type:"question-circle",
          colorType:'#999999',
          verifyDesc:'未进行'
        },
        {
          key:2,
          type:"clock-circle",
          colorType:'#FF9B46',
          verifyDesc:'进行中'
        },
        {
          key:1,
          type:"check-circle",
          colorType:'#4266E5',
          verifyDesc:'完成'
        },
        {
          key:3,
          type:"close-circle",
          colorType:'#FF6A6A',
          verifyDesc:'失败'
        },
      ],

      //申请退票相关操作
      refundFill: false,  //填写退票信息显隐
      typeSize: 0,  //1 图片
      isVisable: false,   //退票展示标识
      isInvoice: false,  //退票作废展示
      isInvoiceType: true,   // 判断发票格式
      isInvoiceList: [116,201,202,203,204,205,206,207,208],  //发票作废标识展示包含的状态


      //------------邀请验证相关操作
      invitationShow: false,
      invitationNewShow:false,
      invitationCodeNewData:{},
      currentRowData:{},
      // 单文件核验
      singleInvitationNewShow:false,
      dataType_:'',
      singleDataVerificationData:{},
      inContent: {},  //发票内容

      //----结算相关操作
      entId: null,  //企业id
      //年季月开票金额与限制金额
      amountColumn: {
        yearLimit: 470000000,  //企业年度封顶金额470万元
        ladderLimit: 30000000,  //跨阶梯封顶金额30万元（季度）
        yearMoney: 0,  //年度开票金额
        quarterMoney: 0,  //当季开票金额
        inSeasonLimit: 0,  //当季提醒限额--双定模式
        quarterLimit: 0, //季度最大开票限额
        monthMoney: 0,  //当月开票金额
        monthLimit: 0, //当月最大开票限额(服务模式)
        digitalMonthLimit: 0, //数电月度最大限额
        yearTotalMoney: 0,  //年度剩余开票金额
        quarterTotalMoney: 0,  //季度剩余开票金额
        monthTotalMoney: 0,  //月度剩余开票金额
        digitalRemaining: 0, //数电剩余额度
        limitOfHalf: 0, //数电限额1/2
        limitOneThird: 0, //数电限额1/3
      },
      digitalInfo:{
        approvalMethod: null, ////核定方式 1-查账征收 2-核定征收-双定 3-核定征收-征收率 4-核定征收-应纳税所得率
        bePaidStatus: false,  //true-有待支付的订单
        pageSource: 3,  //3-单笔结算  4-批量结算
        moneyTotal: 0,  //本次结算的发票金额总和
        limitStatus: false,  //企业是否超限额（超征收，数电，服务模式，470万）
      },
      //弹层展示各类金额
      promptColumn:{
        totalYear: 0,  //年度累计开票金额（含本次）
        totalQuarter: 0,  //季度累计开票金额（含本次）
        totalMonth: 0,  //月度累计开票金额（含本次）
        digitalMonthLimit: 0,   //数电月限额
        monthLimit: 0,  //服务模式月限额
        quarterLimit: 0,  //季度最大开票限额
        digitalRemaining: 0,   //数电剩余额度
        yearTotalMoney: 0,  //年度剩余开票金额
        quarterTotalMoney: 0,  //季度剩余开票金额
        monthTotalMoney: 0,  //月度剩余开票金额
      },
      //未跨阶梯（预估费用）
      balanceConfig: {
        width: '450px',
        visible: false,
        ladderStatus: 1, //1-未跨阶梯  2-跨阶梯
        pendingOrders: 1, //1-有待支付订单  2-无待支付订单
        source: 4,    //来源  3-单笔结算  4-批量结算
      },
      //跨阶梯（展示本季和历史费用）
      batchConfig:{
        width: '850px',
        visible: false,
        ladderStatus: 1, //1-未跨阶梯  2-跨阶梯
        pendingOrders: 1, //1-有待支付订单  2-无待支付订单
        source: 3,    //来源  3-单笔结算  4-批量结算
      },
      //单笔结算-展示超限额等超额判断弹层
      promptConfig: {
        width: '650px',
        visible: false,    //modal展示状态
        modalTitle: '',   //modal层的标题
        title: '',     //标题
        content: '',  //内容
        okText: '继续提交',    //确定文字
        okType: 'primary',    //确定类型
        cancleText: '暂不提交',    //取消文字
        cancleType: 'default',    //取消类型
        expandText: '',    //拓展文字
        source: 3,    //来源  1-在途  2-无在途  3-单笔结算  4-批量结算
        category: '',    //类别
      },
      //批量结算-展示超限额等超额判断弹层
      overLimitConfig: {
        width: '750px',
        visible: false,
        modalTitle: '',
        pendingOrders: 1, //1-有待支付订单  2-无待支付订单
        category: '',    //类别  cnd-超470万  sd-超数电月限额  czs-超征收限额  cfwms-超服务模式限额
        settlableLimit: 0,   //可结算额度
      },
      //征收方式变更弹层
      collectionConfig: {
        width: '800px',
        visible: false,
        source: '',   //来源   3-单笔结算  4-批量结算
        base: 'list',   //出发地   apply-申请开票   list-开票列表
        isOverrun: 1
      },
      //有待支付订单&&未跨阶梯弹层
      bePaidConfig: {
        width: '800px',
        visible: false,
        ladderStatus: 1, //1-未跨阶梯  2-跨阶梯
        pendingOrders: 1, //1-有待支付订单  2-无待支付订单
        source: 3,    //来源  1-在途  2-无在途  3-单笔结算  4-批量结算
      },
      balanceCheckList: [],  //跨阶梯传递的选中数据
      balanceCheckNewList: [],  //跨阶梯传递的选中数据
      overLimitCheckList: [],
      toBePaidList: [],  //结算待支付的数据

      //提示信息
      undoConfig:{
        width: '500px',  //modal宽度
        visible: false,    //modal展示状态
        modalTitle: '', //modal层的标题
        title: '',     //标题
        subTitle: '',     //副标题
        icon: '',
        content: '',  //内容
        okText: '',    //确定文字
        okType: '',    //确定类型
        cancleText: '',    //取消文字
        cancleType: '',    //取消类型
        source: 1,    //来源  ''发送成功  1撤销并删除 2邀请验证 3确认寄送 4删除草稿 6订单创建成功 7订单创建失败 8订单创建失败
      },
      //下载发票
      downloadFormatInfo: {
        visible: false,
      },

      //////---------开票失败
      invoiceFailed: {
        userStatus: false,  //变更开票员弹层
        revokeStatus: false,  //撤销开票弹层弹层
        invoicePendding: false,  //正在开票中弹层提示
      },
      //开票员信息
      invoiceInfo: {},
      //变更开票员弹层
      invoicerNewList: [],  //开票员数据
      //------撤销开票弹层弹层
      //本次费用
      revokeLoading: false,
      revokeData: [],
      revokeColumns: [
        {
          title: '开票金额',
          dataIndex: 'amount',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 120,
          align: 'center'
        },
        {
          title: '应缴个税',
          dataIndex: 'personalTaxMoney',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 100,
          align: 'center'
        },
        {
          title: '应缴增值税',
          dataIndex: 'vatMoney',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 100,
          align: 'center'
        },
        {
          title: '应缴附加税',
          dataIndex: 'additionalTaxMoney',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 100,
          align: 'center'
        },
        {
          title: '开票服务费',
          dataIndex: 'serviceChargeMoney',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 100,
          align: 'center'
        },
      ],
      //历史费用
      historyData: [],
      historyColumns: [
        {
          title: '开票金额',
          dataIndex: 'amount',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 120,
          align: 'center'
        },
        {
          title: '应缴增值税',
          dataIndex: 'vatMoney',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 120,
          align: 'center'
        },
        {
          title: '应缴附加税',
          dataIndex: 'additionalTaxMoney',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 120,
          align: 'center'
        },
        {
          title: '减免个税',
          dataIndex: 'personalTaxMoneyDiff',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 120,
          align: 'center'
        },
        {
          title: '减免服务费',
          dataIndex: 'serviceChargeMoneyDiff',
          customRender: (text,record) => {
            if (text != null){
              return Math.abs(Math.round(text * 100)/10000) + '元'
            }else {
              return '-'
            }
          },
          width: 120,
          align: 'center'
        },
      ],
      //重新邀请核验
      OpenModalConfig: {
        visible: false,
        componentName:'',
        data:{}
      },
      // 倒计时 配置
      CountDownConfig: { label: '', time: 15, isRun: false, res:{} },
      // 用于控制【确认已核验】按钮的显示隐藏    当点击完一次之后就显示
      showConfirmLogged:false

    }
  },
  created() {
    if (this.$route.query.bizId){
      this.id = this.$route.query.bizId;
    }
    //判断重开票进来的
    if(this.$route.query.invoiceType){
      this.flowCode = 20000003;
    }
  },
  mounted() {
    this.getListDetails();
    this.CountDownConfig.res = useCountDown(this,{ defaultLabel: '重新邀请核验', reoperateLabel: '后重新发送',  time: 60, startEvent: () => {}, endEvent: ()=>{}})
  },
  methods:{
    //父组件返回成功调用(快递成功,订单创建成功，订单创建失败)
    fatherMethod(config){
      //确定撤销
      this.$nextTick(()=>{
        this.undoConfig.visible = false;
      })

      //source来源   ''发送成功  1撤销并删除 2邀请验证 3确认寄送 4删除草稿 6订单创建成功 7订单创建失败  8订单创建失败
      if (config.source == 6){
        //立即支付操作  支付id---config.ext
        let arr = [];
        arr.push(config.ext);
        this.paymentInvoice(arr);
      }else if (config.source == 7){
        //跳转收银台
        this.$router.push({
          path: '/myAccount/accountManage',
          po: 'paymentInvoice'
        });
      }
    },
    getTableData(){
      this.getListDetails(this.id);
    },
    //  ---------------------------- 开票失败相关操作 ↓ -----------------------
    //重新邀请核验
    reInviteVerification(){
      // this.detailsData.entId
      // this.detailsData.invoiceUserId
      const param = {eleIssuerId: this.detailsData.invoiceUserId, entId: this.detailsData.entId}
      let params1 = {};
      params1.entId = this.detailsData.entId;
      params1.userId = this.detailsData.invoiceUserId;  //开票员ID
      getEleIssuerAuth(param).then(res => {
        if (res.success == true) {
          this.OpenModalConfig.componentName = 'InvitationVerification'
          this.OpenModalConfig.data = { startEvent: this.startEvent, dbData: res.result, param, params1, RefreshDetail: this.RefreshDetail,RefreshModal: this.RefreshModal}
          this.OpenModalConfig.visible = true
          this.showConfirmLogged = true

        } else {
          this.$message.warning(res.message)
        }
      })
    },
    RefreshDetail(data){
      if (data == 1){
        this.getListDetails('',true);
      }else {
        this.getListDetails();
      }
    },
    //调用弹层
    RefreshModal(data){
      this.invoiceFailed.invoicePendding = data;
    },
    //关闭弹层
    OpenModalCloseEvent(v, data){
      this.OpenModalConfig.visible = v
      if (data&&data) {
        // 处理后续操作
      }
    },
    // 开始到计时
    startEvent(){
      this.CountDownConfig.res.startTimingEvent()
    },
    //确认已登录
    confirmLogged(){
      //获取是否需要人脸识别
      let params = {};
      params.entId = this.detailsData.entId;
      params.eleIssuerId = this.detailsData.invoiceUserId;   //开票员ID

      getInvoiceWhetherUserFace(params).then(res => {
        if (res.success) {
          let data = res.result;
          if (data === false){
            this.verificationInvoicerStatus();
          }else {
            this.$message.warning('开票员暂未核验，请重新进行核验！');
          }
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //发起登录操作
    verificationInvoicerStatus(){
      this.invoiceFailed.invoicePendding = true;
      let params = {};
      params.entId = this.detailsData.entId;
      params.invoiceUserId = this.detailsData.invoiceUserId;  //开票员ID
      queryConfirmedVerified(params).then(res => {
        if (res.success) {
          this.getListDetails('',true);
          // this.$message.success('操作成功');
        }else{
          //开票未完成状态重复开票
          if(res.code == -210101324){
            this.invoiceFailed.invoicePendding = true;
          }else {
            this.invoiceFailed.invoicePendding = false;
            this.$message.warning(res.message);
          }
        }
      })
    },
    //变更开票员
    changeInvoiceUser(){
      this.invoiceFailed.userStatus = true;
    },
    //请选择开票员
    handleChange(value,option){
      //获取其他信息  option.data.attrs.info
      if (value){
        let data = option.data.attrs.info;
        // console.log('开票员其他信息==>',data)
        this.invoiceInfo = data;
        this.invoiceInfo.invoiceUserId = value;
      }else{
        this.invoiceInfo = {};
      }
    },
    //变更开票员--确定
    userSure(){
      if (this.invoiceInfo && this.invoiceInfo.name){
        //请求接口变更开票员  成功关闭弹层  失败重新选择开票员
        let params = {};
        params.invoiceUserId = this.invoiceInfo.id;   //开票人ID
        params.invoiceUserType = this.invoiceInfo.type;    //开票人类型 1 法人开票 2 代办开票 3 渠道
        params.taxId = this.detailsData.id;   //发票ID

        queryInvoiceUser(params).then(res => {
          if (res.success) {
            this.invoiceFailed.userStatus = false;
            this.$message.warning('提交成功！');
            this.getListDetails();
          }else{
            this.$message.warning(res.message);
          }
        })
      }else {
        this.$message.warning('请选择开票员');
      }
    },
    //变更开票申请
    invoiceApplication(){
      let that = this;
      this.$confirm({
        title: '修改开票信息时，不支持开票金额的修改！',
        content: ' ',
        // icon: '<a-icon type="exclamation-circle" theme="filled" />',
        iconClass: 'exclamation-circle',
        okText: '确认修改',
        okType: 'primary',
        cancelText: '撤销开票',
        onOk() {
          //跳转至申请开票页面（金额和税率不允许更改）
          that.goToEdit();
        },
        onCancel() {
          //调用撤销开票
          that.revokeInvoice();
        },
      });
    },
    //跳转至申请开票页面
    goToEdit(){
      this.$router.push({
        path: '/invoice/applyInvoice',
        query:{
          bizId: this.detailsData.entId,
          detailsId: this.detailsData.id,
          varyType: 1, //区分标识  （金额和税率不允许更改）
        }
      })
    },
    //撤销开票
    revokeInvoice(){
      //调用费用
      this.revokeExpenseCalculation();
      this.invoiceFailed.revokeStatus = true;
    },
    //撤销开票--确定
    revokeSure(){
      let params = {};
      params.taxId = this.detailsData.id;
      invoiceRevokeApplication(params).then(res => {
        if (res.success) {
          this.$message.success('撤销成功！');
          this.invoiceFailed.revokeStatus = false;
          this.getListDetails();
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //撤销开票--取消
    revokeCancle(){
      this.invoiceFailed.revokeStatus = false;
    },
    //获取撤销费用计算信息
    revokeExpenseCalculation(){
      let params = {};
      params.taxId = this.detailsData.id;
      invoiceRevokeCostInfo(params).then(res => {
        if (res.success) {
          this.revokeLoading = false;
          let data = cloneObject(res.result.entChargeInfoVOS[0]);

          this.revokeData = data.chargeInfoList || [];  //本次费用列表

          //历史费用列表
          if (data.chargeInfoDiffList && data.chargeInfoDiffList.length > 0 && data.chargeInfoDiffTotal){
            let arrList = data.chargeInfoDiffList || [];
            this.historyData = arrList;
          }else {
            this.historyData = [];
          }
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //获取开票员信息
    getUserManageList(){
      let entId = this.entId;
      queryInvoiceManage(entId).then(res => {
        if (res.success) {
          let data = res.result || [];
          // type 1 法人开票(经营者) 2 代办开票(内部员工) 3 开票人-身份渠道
          //处理过滤非内部员工数据
          this.invoicerNewList = data.filter(item => item.type != 2);
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //  ---------------------------- 申请退票相关操作 ↓ -----------------------
    //申请退票
    applyRefund(){
      //判断如果是数电票，不校验可退张数
      if(this.detailsData.ticketType == 2){
        if (this.detailsData.id && this.detailsData.canReturnAmount){
          this.refundFill = true;
        }else{
          this.$message.warning('可退金额不足');
        }
      }else{
        if (this.detailsData.id && this.detailsData.canReturnBillNum && this.detailsData.canReturnAmount){
          this.refundFill = true;
        }else{
          this.$message.warning('可退张数或可退金额不足');
        }
      }
    },
    //子组件调用父组件
    handleUseFather(){
      this.getListDetails();
    },
    //取消
    handleFather(){
      this.$nextTick(function(){
        this.refundFill = false;
      })

      this.getListDetails(this.id);

      // this.isVisable = true;
      // if(this.typeSize === 1){
      //   this.isInvoice = true;
      // }else {
      //   this.isInvoice = false;
      // }
    },
    //跳转退票详情
    seeReturnTicket(){
      this.$router.push({
        path: '/invoice/refundTicketRecord',
        query:{
          bizId: this.detailsData.noFinishReturnTaxId,
        }
      })
    },
    //  ---------------------------- 进度条   start ↓ -----------------------
    //获取开票进度条
    getListProgress(id){
      getInvoiceProgress(id).then(res => {
        if (res.success) {
          this.progressList = res.result || [];
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //  ---------------------------- 进度条（待撤销核验） ↓ -----------------------
    /**
     * 待撤销核验
     */
    revokeEvent(){
      const id = this.id
      taxSettleRevokedSMS({invoiceId:id}).then(res=>{
        if(res.success==true){
          this.$message.success('核验短信已发送成功')
        }else{
          this.$message.warning(res.message || '核验短信发送失败')
        }
      })
    },
    //  ---------------------------- 进度条（邀请核验操作） ↓ -----------------------
    //邀请核验
    invitation(){
      //邀请验证增加弹层
      this.$nextTick(()=>{
        this.invitationShow = true;
      });
    },
    invitationValidationNew(nodeItem){
      // 操作方式 0-无 1-显示邀请核验接口 2-显示立即支付按钮 3-显示签署渠道协议按钮 4-显示撤销法人核验 5-结算
      const {opDis} = nodeItem
      if(opDis==1){
        const {id} = this.detailsData
        taxInvoiceCatalogById({id}).then(res=>{
          if(res.success==true){
            if(!this.isType.isNullOrUnDef(res.result) && this.isType.isArray(res.result)){
              if(res.result.length==1){
                //邀请验证增加弹层
                this.inContent = this.detailsData;
                this.invitationShow = true;
              }
              if(res.result.length>1){
                this.currentRowData = this.detailsData
                this.invitationCodeNewData = res.result
                this.invitationNewShow = true
              }
            } else{
              // this.$message.warning('当前')
            }
          }else{
            this.$message.warning(res.message)
          }
        })
      }
      // this.invitationNewShow = true
    },
    icnEvent(type,data){
      const actionList = {
        'close':()=>{
          this.reload();
          this.getTableData();
          this.invitationNewShow = data
        },
        // 批量核验 关闭
        'SVIclose':()=>{
          this.reload();
          this.getTableData();
          this.batchVerificationNewShow = data
        },
        // 批量核验
        'SVI':()=>{
          this.singleDataVerificationData = data
          this.dataType_ = 'SVI'
          this.singleInvitationNewShow = true
        },
        // 单独发送核验邀请
        'IV':()=>{
          this.singleDataVerificationData = data
          this.dataType_ = 'IV'
          this.singleInvitationNewShow = true
        },
        'SDVClose':()=>{
          this.singleInvitationNewShow = data
          // this.reload();
          // this.getTableData();
        },
        // 发送核验短信
        'SDVSMS':()=>{

        },
        // 拷贝二维码
        'SDVQRCode':()=>{

        }
      }
      actionList[type] && actionList[type]()
    },
    //关闭邀请验证弹层
    handleCodeFather(){
      this.$nextTick(function(){
        this.invitationShow = false;
      })
      this.getListDetails(this.id);
    },
    //  ---------------------------- 进度条（待结算操作） ↓ -----------------------
    //结算
    singleBalance(){
      this.digitalInfo.pageSource = 3;

      //调取比对有无进行中的票并且数电额度是否一致
      this.ongoingTicketsDigitalCreditLimit();
    },
    //-------------------------结算与批量结算（弹层成功和失败回调）  start ↓------------------
    //···情况一： 无待支付订单 && 未跨阶梯   预估费用弹层 ==> 成功回调
    balanceMethod(configure){
      let config = configure;
      config.ladder = false;  //标注为未跨阶梯
      //开票结算生成订单id
      this.getPaymentId(config);
    },
    //···情况二： 有待支付订单 && (未跨阶梯 || 跨阶梯)  有待支付订单选择弹层 ==> 成功回调
    toBePaidMethod(config){
      //关闭有待支付订单弹层
      this.$nextTick(()=> {
        this.bePaidConfig.visible =  false;
      })

      //先清空数组 再赋值数据
      // this.balanceCheckList = [];
      this.balanceCheckList = config.balanceCheckList;
      //ladderStatus  1-未跨阶梯  2-跨阶梯
      if(config.ladderStatus == 1){
        //打开预估费用弹层
        this.$nextTick(()=> {
          this.balanceConfig = {
            width: '800px',
            visible: true,    //modal展示状态
            ladderStatus: config.ladderStatus, //1-未跨阶梯  2-跨阶梯
            pendingOrders: config.pendingOrders, //1-有待支付订单  2-无待支付订单
            source: 4, //3-单笔结算  4-批量结算
          };
        })
      }else {
        //打开确认费用弹层
        this.$nextTick(()=> {
          this.batchConfig = {
            width: '800px',
            ladderStatus: config.ladderStatus, //1-未跨阶梯  2-跨阶梯
            pendingOrders: config.pendingOrders, //1-有待支付订单  2-无待支付订单
            visible: true,    //modal展示状态
            mark: config.mark,
            source: 4, //3-单笔结算  4-批量结算
          };
        })
      }
    },
    //有待支付订单 && 未跨阶梯  确认费用弹层 ==> 返回上一步回调
    backBePaidCancle(data){
      //关闭预估费用弹层
      this.$nextTick(()=> {
        this.balanceConfig.visible =  false;
      })

      //先清空数组 再赋值数据
      // this.balanceCheckList = [];
      this.balanceCheckList = this.balanceCheckNewList;
      //打开有待支付订单弹层
      this.$nextTick(()=> {
        this.bePaidConfig = {
          width: '800px',
          visible: true,    //modal展示状态
          pendingOrders: 1, //1-有待支付订单  2-无待支付订单
          ladderStatus: data.ladderStatus, //1-未跨阶梯  2-跨阶梯
          source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
        };
      })
    },
    //···情况三： 无待支付订单 && 超限额  单笔结算提示弹层 ==> 成功回调
    //超限额等超额判断弹层---primary按钮事件
    fatherPromptMethod(data){
      this.$nextTick(()=>{
        this.promptConfig.visible = false;
      })
    },
    //超限额等超额判断弹层---拓展按钮事件
    fatherPreserveMethod(data){
      // console.log('接收到了子组件带来的参数',data)
      this.$nextTick(()=> {
        this.promptConfig.visible = false;
      })

      //
      if(data.source == 3 && data.category == 'czs'){
        //超征收限额
        this.$nextTick(()=>{
          //展示变更征收方式弹层
          this.collectionConfig = {
            width: '800px',
            visible: true,
            source: 3,   //来源   3-单笔结算  4-批量结算
            base: 'list',   //出发地   apply-申请开票   list-开票列表
            isOverrun: 1
          }
        })
      }else {
        this.$nextTick(()=> {
          this.overLimitConfig = {
            width: '750px',
            visible: true,
            category: data.category,
            pendingOrders: data.pendingOrders, //1-有待支付订单  2-无待支付订单
            ladderStatus: data.ladderStatus, //1-未跨阶梯  2-跨阶梯
            source: data.source, //3-单笔结算  4-批量结算
            settlableLimit: data.settlableLimit, //可结算额度
          }
        })
      }

    },
    //···情况四： (有待支付订单 || 无待支付订单) && 超限额  展示超限额等超额判断弹层 ==> 成功回调
    //成功回调 超限额等超额判断弹层（批量结算）
    overLimitMethod(config){
      this.$nextTick(()=>{
        this.overLimitConfig.visible = false;
      })

      //先清空数组 再赋值数据
      // this.balanceCheckList = [];
      this.balanceCheckList = config.balanceCheckList;

      //下一步调取费用弹层
      this.$nextTick(()=> {
        this.batchConfig = {
          width: '850px',
          visible: true,    //modal展示状态
          ladderStatus: config.ladderStatus, //1-未跨阶梯  2-跨阶梯
          pendingOrders: config.pendingOrders, //1-有待支付订单  2-无待支付订单
          category: config.category,  //类别
          source: 4, //3-单笔结算  4-批量结算
        };
      })
    },
    //点击此处---成功回调 超限额等超额判断弹层（批量结算）
    overLimitBackCancle(config){
      this.$nextTick(()=> {
        this.overLimitConfig.visible = false;
      })
      if (config.category == 'sd'){
        //数电
        this.$nextTick(()=>{
          this.promptConfig = {
            width: '650px',
            visible: true,    //modal展示状态
            content: '联系客服，提高数电月核定额度',
            okText: '关闭',    //确定文字
            okType: 'primary',    //确定类型
            cancleText: '',    //取消文字
            cancleType: '',    //取消类型
            expandText: '返回上一步',    //拓展文字
            big: true,    //按钮
            source: 4,    //来源  3-单笔结算  4-批量结算
            category: config.category,    //类别
            pendingOrders: config.pendingOrders, //1-有待支付订单  2-无待支付订单
            settlableLimit: config.settlableLimit, //可结算额度
          };
        })
      }else if (config.category == 'czs'){
        //超征收限额
        this.$nextTick(()=>{
          //展示变更征收方式弹层
          this.collectionConfig = {
            width: '800px',
            visible: true,
            source: 4,   //来源   3-单笔结算  4-批量结算
            base: 'list',   //出发地   apply-申请开票   list-开票列表
            isOverrun: 1,
            pendingOrders: config.pendingOrders, //1-有待支付订单  2-无待支付订单
            defaultCheckList: config.defaultCheckList,  //本次申请
            toPayCheckList: config.toPayCheckList,  //待支付订单
            settlableLimit: config.settlableLimit, //可结算额度
          }
        })
      }
    },
    //···情况五： (有待支付订单 || 无待支付订单) && （跨阶梯 || 超限额）  确认费用弹层 ==> 成功回调
    //跨阶梯成功回调（批量结算）
    batchMethod(configure){
      let config = configure;
      config.ladder = true;  //标注为跨阶梯
      //TODO 判断无已完成的发票 &&  首次开票金额超过您核定额度的1/3
      // let firstStatus = true;
      // if (firstStatus){
      //   this.$nextTick(()=>{
      //     this.excessConfig.visible = true;
      //   })
      // }else {
      //   //开票结算生成订单id
      //   this.getPaymentId(config);
      // }
      //开票结算生成订单id
      this.getPaymentId(config);
    },
    //返回上一步回调 超限额等超额判断弹层（批量结算）
    backLimitCancle(config){
      // console.log('我调到批量结算超额弹层的子组件了',config)
      this.$nextTick(()=> {
        this.batchConfig.visible = false;
      })

      //pendingOrders: 1, //1-有待支付订单  2-无待支付订单
      if (config.mark == 1){
        let list = cloneObject(this.balanceCheckList);
        this.balanceCheckList = list.filter(item => item.payCheckStatus == true);
      }

      //ladderStatus  1-未跨阶梯  2-跨阶梯
      if (config.ladderStatus == 2){
        this.$nextTick(()=> {
          this.bePaidConfig.visible = true;
        })
      }else{
        this.$nextTick(()=> {
          this.overLimitConfig.visible = true;
        })
      }
    },
    //···情况六：  变更征收方式弹层 ==> 成功回调
    //征收方式变更返回回调 返回上一步（批量结算）
    fatherBackMethod(config){
      // console.log('我调到征收方式的子组件了！');
      //关闭变更征收方式弹层
      this.$nextTick(()=> {
        this.collectionConfig.visible = false;
      })

      if(config.source == 3){
        this.$nextTick(()=> {
          this.promptConfig.visible = true;
        })
      }else{
        this.$nextTick(()=> {
          this.overLimitConfig.visible = true;
        })
      }
    },
    //开票结算生成订单id
    getPaymentId(config){
      let params = {};
      params.taxIds = config.payIdList;
      invoiceSettlement(params).then(res => {
        if (res.success) {
          if (res.result){
            let data = cloneObject(res.result.entChargeInfoVOS[0]);
            if(!config.ladder){
              this.$nextTick(()=>{
                this.balanceConfig.visible = false;
              })
            }else{
              this.$nextTick(()=>{
                this.batchConfig.visible = false;
              })
            }

            //订单id   data.payOrder
            this.$nextTick(()=>{
              this.undoConfig = {
                width: '450px',  //modal宽度
                visible: true,    //modal展示状态
                modalTitle: '',
                title: '',     //标题
                subTitle: '订单创建成功！',   //副标题
                content: '',  //内容
                okText: '立即支付',    //确定文字
                okType: 'primary',    //确定类型
                cancleText: '结算其他订单',    //取消文字
                cancleType: 'default',    //取消类型
                source: 6,    //来源
                ext: data.payOrder,     //拓展参数
                cancleRoute: '/invoice/invoiceQueryNew?pagetab=9',     //跳转路由
              }
            })
          }
        }else{
          //判断订单状态弹层
          let code = res.code;
          //作废失败-原订单部分支付单在途/已支付
          if (code.includes(30165)){
            this.$nextTick(()=>{
              this.undoConfig = {
                width: '450px',  //modal宽度
                visible: true,    //modal展示状态
                modalTitle: '',
                title: '',     //标题
                subTitle: '订单创建失败!\n' + '原订单正在支付中，请完成原订单支付后再提交新订单',   //副标题
                content: '',  //内容
                okText: '支付原订单',    //确定文字
                okType: 'primary',    //确定类型
                cancleText: '关闭',    //取消文字
                cancleType: 'primary',    //取消类型
                source: 7,    //来源
                cancleRoute: '/invoice/invoiceQueryNew',     //跳转路由
              }
            })
          }
          //作废失败-原订单全部支付完成
          else if(code.includes(30166) || code.includes(30167)){
            this.$nextTick(()=>{
              this.undoConfig = {
                width: '450px',  //modal宽度
                visible: true,    //modal展示状态
                modalTitle: '',
                title: '',     //标题
                subTitle: '订单创建失败!原订单可能已支付，请重新选择要结算的订单!',   //副标题
                content: '',  //内容
                okText: '',    //确定文字
                okType: '',    //确定类型
                cancleText: '返回发票列表',    //取消文字
                cancleType: 'primary',    //取消类型
                source: 8,    //来源
                cancleRoute: '/invoice/invoiceQueryNew',     //跳转路由
              }
            })
          }
          else{
            this.$message.warning(res.message);
          }
        }
      })
    },
    //-------------------------结算与批量结算（金额获取与比对超额逻辑）  start ↓------------------
    //调取比对有无进行中的票并且数电额度是否一致
    async ongoingTicketsDigitalCreditLimit(){
      //获取企业是否有“开票中”或“开票失败”状态的发票
      const queryNotFinishedTicket = await getNotFinishedTicket(this.entId);
      let aFunStatus = this.queryNotFinishedTicketFun(queryNotFinishedTicket);
      //检查数电额度是否一致
      // const checkBatteryToLimit = await checkBatteryLimit(this.entId);
      // let bFunStatus = this.checkBatteryToLimitFun(checkBatteryToLimit);

      if(aFunStatus){
        //调用获取费用和执行金额判断超额
        this.modifyAsynchronous();
      }else{
        //提示存在未完成的开票，不可继续开票
        this.$nextTick(()=>{
          this.undoConfig = {
            width: '500px',  //modal宽度
            visible: true,    //modal展示状态
            modalTitle: '',
            title: '',     //标题
            subTitle: '',     //副标题
            content: '您有尚未完成的开票任务，请优先完成“开票中”及“开票失败”状态的任务处理！',  //内容
            okText: '关闭',    //确定文字
            okType: 'primary',    //确定类型
            cancleText: '',    //取消文字
            cancleType: '',    //取消类型
            source: 9,    //来源
          }
        })
      }


      // if(!aFunStatus && bFunStatus){
      //   //提示存在未完成的开票，不可继续开票
      //   this.$nextTick(()=>{
      //     this.undoConfig = {
      //       width: '500px',  //modal宽度
      //       visible: true,    //modal展示状态
      //       modalTitle: '',
      //       title: '',     //标题
      //       subTitle: '',     //副标题
      //       content: '您有尚未完成的开票任务，请优先完成“开票中”及“开票失败”状态的任务处理！',  //内容
      //       okText: '关闭',    //确定文字
      //       okType: 'primary',    //确定类型
      //       cancleText: '',    //取消文字
      //       cancleType: '',    //取消类型
      //       source: 9,    //来源
      //     }
      //   })
      // }else {
      //   //提示数电额度是否一致
      //   this.$nextTick(()=>{
      //     this.promptConfig = {
      //       width: '650px',
      //       visible: true,    //modal展示状态
      //       content: '企业账户中存在未知发票数据，暂不支持提交结算，请联系客服!',
      //       okText: '关闭',    //确定文字
      //       okType: 'primary',    //确定类型
      //       cancleText: '',    //取消文字
      //       cancleType: '',    //取消类型
      //       expandText: '',    //拓展文字
      //       big: false,    //按钮
      //       source: '5',    //来源  5-数电已开金额与税务局不一致提示
      //       category: 'sd',    //来源  5-数电已开金额与税务局不一致提示
      //     };
      //   })
      // }

    },
    //修改异步为同步执行接口
    async modifyAsynchronous(){
      const getEntTaxPayOrder = await queryTaxPayOrder(this.entId);
      this.getEntTaxPayOrderFun(getEntTaxPayOrder);    //获取企业有无待支付的订单

      const getMoneyInfo = await getEntMoneyInfo(this.entId);
      this.getMoneyInfoFun(getMoneyInfo);    //获取开票金额

      const getEntSvConfInfo = await getEntSvConf(this.entId)
      this.getMonthLimitFun(getEntSvConfInfo);    //获取当前企业服务模式下的月度最大限额

      const getEntQuarterAmountInfo = await getEntQuarterAmount(this.entId);
      this.getQuarterAmountFun(getEntQuarterAmountInfo);    //获取当季提醒限额

      const getSendListInfo = await getSendList(this.entId);
      this.getPartyListFun(getSendListInfo);    //获取数电最大限额和可开额度

      if (!this.payStatus){
        //比对该企业总和是否超限额
        this.limitTotal();
      }
    },
    //比对该企业总和是否超限额
    limitTotal(){
      let total; //本次开票金额
      //有待支付的订单
      if (this.digitalInfo.bePaidStatus){
        let payTotal = this.toBePaidList.reduce((sum, item) => { return sum + item.amount }, 0);
        total = accAdd(this.digitalInfo.moneyTotal,payTotal);
      }else{
        total = this.digitalInfo.moneyTotal;
      }

      //已开金额 + 预开金额  是否超过   剩余金额
      let totalMonth = accAdd(total,this.amountColumn.monthMoney);   //该月总用额度
      let totalQuarter = accAdd(total,this.amountColumn.quarterMoney);   //该季度总用额度
      let totalYear = accAdd(total,this.amountColumn.yearMoney);   //该年总用额度

      //计算可结算额度
      let totalNewQuarter;
      //判断核定方式
      this.digitalInfo.approvalMethod == 2  ? totalNewQuarter = this.amountColumn.monthMoney : totalNewQuarter = this.amountColumn.quarterMoney;

      //季度剩余额度 = 季度最大开票限额 - 已开金额 （根据征收方式   双定-月度已开金额  征收率-季度已开金额）
      this.amountColumn.quarterTotalMoney = accSub(this.amountColumn.quarterLimit,totalNewQuarter);

      // console.log('已开金额',totalNewQuarter)
      // console.log('季度最大开票限额',this.amountColumn.quarterLimit)
      // console.log('季度剩余额度',this.amountColumn.quarterTotalMoney)

      //月度剩余额度 = 当月最大开票限额 - 当月已开金额
      this.amountColumn.monthTotalMoney = accSub(this.amountColumn.monthLimit,this.amountColumn.monthMoney);

      this.promptColumn.totalYear = conversionElement(totalYear);  //年度累计开票金额（含本次）
      this.promptColumn.totalQuarter = conversionElement(totalQuarter);  //季度累计开票金额（含本次）
      this.promptColumn.totalMonth = conversionElement(totalMonth);  //月度累计开票金额（含本次）
      this.promptColumn.monthLimit = conversionElement(this.amountColumn.monthLimit);  //服务模式月限额
      this.promptColumn.quarterLimit = conversionElement(this.amountColumn.quarterLimit);  //季度最大开票限额
      this.promptColumn.digitalMonthLimit = conversionElement(this.amountColumn.digitalMonthLimit);  //数电月限额
      this.promptColumn.digitalRemaining = conversionElement(this.amountColumn.digitalRemaining);  //数电剩余额度

      checkLimit(this.entId,total).then(res => {
        if (res.success) {
          // this.digitalInfo.limitStatus = false;
          //判断企业开票总和是否跨阶梯
          this.crossingStairs(total);
        }else{
          //判断展示对应超额弹层
          let code = res.code;
          // console.log('比对超限额',res.message,code)
          //开票金额超470万
          if(code == -210101311){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus){
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'cnd',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.yearTotalMoney,  //可结算额度(年度剩余额度)
                };
              })
            }else{
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,
                    category: 'cnd',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您的开票金额累计' +
                    this.promptColumn.totalYear +
                    '元（含本次），已超过470万/年！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'cnd',    //类别
                    source: 4,
                    pendingOrders: 2,  //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.yearTotalMoney,  //可结算额度(年度剩余额度)
                  };
                })
              }
            }
          }
          //开票金额超征收限额
          else if (code == -210101312){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus) {
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'czs',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.quarterTotalMoney,  //可结算额度(季度剩余额度)
                };
              })
            }else {
              //无待支付订单 && 区分是否单笔结算还是批量结算
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,
                    category: 'czs',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您本次开票金额累计' +
                    this.promptColumn.totalQuarter +
                    '元（含本次），已超过您适用的税收政策：' +
                    this.promptColumn.quarterLimit +
                    '元，本月内不支持新开票！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'czs',    //类别
                    source: 4,
                    pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.quarterTotalMoney,  //可结算额度(季度剩余额度)
                  };
                })
              }
            }
          }
          //开票金额超服务模式限额
          else if (code == -210101313){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus) {
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'cfwms',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.monthTotalMoney,  //可结算额度(月度剩余额度)
                };
              })
            }else {
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,
                    category: 'cfwms',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您本次开票金额累计' +
                    this.promptColumn.totalMonth +
                    '元（含本次），已超过当前服务模式月限额：' +
                    this.promptColumn.monthLimit +
                    '元，本月内不支持新开票！\n' +
                    '您可以在次月提交结算！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'cfwms',    //类别
                    source: 4,
                    pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.monthTotalMoney,  //可结算额度(月度剩余额度)
                  };
                })
              }
            }
          }
          //开票金额超数电月限额
          else if (code == -210101314){
            //判断是否有待支付订单
            if (this.digitalInfo.bePaidStatus) {
              this.$nextTick(()=>{
                this.overLimitConfig = {
                  width: '750px',
                  visible: true,    //modal展示状态
                  category: 'sd',    //类别
                  source: 4,
                  pendingOrders: 1, //1-有待支付订单  2-无待支付订单
                  mark: this.digitalInfo.mark,
                  settlableLimit: this.amountColumn.digitalRemaining,  //可结算额度（数电剩余额度）
                };
              })
            }else {
              if (this.digitalInfo.pageSource == 3){
                this.$nextTick(()=>{
                  this.promptConfig = {
                    width: '650px',
                    visible: true,    //modal展示状态
                    okText: '',    //确定文字
                    okType: '',    //确定类型
                    cancleText: '关闭',    //取消文字
                    cancleType: 'primary',    //取消类型
                    expandText: '',    //拓展文字
                    source: 3,    //来源  3-单笔结算  4-批量结算
                    category: 'sd',    //类别
                  };
                  this.promptConfig.content =
                    '结算失败！\n' +
                    '您本次开票金额累计' +
                    this.promptColumn.totalMonth +
                    '元（含本次），已超过您的月核定额度：' +
                    this.promptColumn.digitalMonthLimit +
                    '元，本月内不支持新开票！\n' +
                    '请联系客服，及时修改限额后再结算，或次月提交结算！'
                })
              }else{
                this.$nextTick(()=>{
                  this.overLimitConfig = {
                    width: '750px',
                    visible: true,    //modal展示状态
                    category: 'sd',    //类别
                    source: 4,
                    pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                    mark: this.digitalInfo.mark,
                    settlableLimit: this.amountColumn.digitalRemaining,  //可结算额度（数电剩余额度）
                  };
                })
              }
            }
          }
          else {
            this.$message.warning(res.message);
          }
        }
      })
    },
    //判断企业开票总和是否跨阶梯
    crossingStairs(num){
      let totalQuarter = accAdd(num,this.amountColumn.quarterMoney);   //该季度总用额度

      // console.log('本次开票金额',num)
      // console.log('季度限额',this.amountColumn.quarterLimit)
      // console.log('季度已开金额',this.amountColumn.quarterMoney)
      // console.log('该季度总用额度',totalQuarter)
      // console.log('阶梯限额',this.amountColumn.ladderLimit)

      //跨阶梯   季度已开金额 <= 30万 && 季度已开金额+本次开票金额 >30万
      if (this.amountColumn.quarterMoney <= this.amountColumn.ladderLimit && totalQuarter > this.amountColumn.ladderLimit){

        //判断是否有待支付订单
        if (this.digitalInfo.bePaidStatus) {
          this.$nextTick(()=> {
            this.bePaidConfig = {
              width: '800px',
              visible: true,    //modal展示状态
              ladderStatus: 2, //1-未跨阶梯  2-跨阶梯
              pendingOrders: 1, //1-有待支付订单  2-无待支付订单
              mark: this.digitalInfo.mark,
              source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
            };
          })
        }else {
          this.$nextTick(()=> {
            this.batchConfig = {
              width: '850px',
              visible: true,    //modal展示状态
              ladderStatus: 2, //1-未跨阶梯  2-跨阶梯
              pendingOrders: 2, //1-有待支付订单  2-无待支付订单
              mark: this.digitalInfo.mark,
              source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
            };
          })
        }
      }else{
        //未跨阶梯
        //判断是否有待支付订单
        if (this.digitalInfo.bePaidStatus) {
          this.$nextTick(()=> {
            this.bePaidConfig = {
              width: '800px',
              visible: true,    //modal展示状态
              ladderStatus: 1, //1-未跨阶梯  2-跨阶梯
              pendingOrders: 1, //1-有待支付订单  2-无待支付订单
              mark: this.digitalInfo.mark,
              source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
            };
          })
        }else {
          let width;
          if (this.digitalInfo.pageSource == 3){
            width = '450px';
          }else {
            width = '800px';
          }
          //setTimeout  解决调用接口与弹层展示同时执行
          setTimeout(()=>{
            this.$nextTick(()=> {
              this.balanceConfig = {
                width: width,
                visible: true,    //modal展示状态
                ladderStatus: 1, //1-未跨阶梯  2-跨阶梯
                pendingOrders: 2, //1-有待支付订单  2-无待支付订单
                mark: this.digitalInfo.mark,
                source: this.digitalInfo.pageSource, //3-单笔结算  4-批量结算
              };
            })
          },1000);
        }
      }
    },
    //获取企业是否有“开票中”或“开票失败”状态的发票
    queryNotFinishedTicketFun(res){
      if (res.success) {
        if (res.result){
          //true 代表存在未完成的开票，不可继续开票
          return false;
        }else {
          return true;
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //检查数电额度是否一致
    checkBatteryToLimitFun(res){
      if (res.success) {
        if (res.result){
          // true 没问题
          return true;
        }else {
          return false;
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取企业有无待支付的订单
    getEntTaxPayOrderFun(res) {
      if (res.success) {
        if (res.result){
          let data = res.result || [];
          if (data.length > 0){
            //有待支付的订单
            this.digitalInfo.bePaidStatus = true;
            //先清空数组 再赋值数据
            let newData = cloneObject(data);
            newData.forEach(obj => {
              obj.checkShow = true;
              obj.pendingOrders = 1;
            });
            this.toBePaidList = newData;

            //待支付的撤销
            if (this.payStatus){
              newData.forEach(obj => {
                obj.checkShow = true;
              });
              this.payCheckList = newData;
              this.$nextTick(()=> {
                this.payRevokeConfig.visible = true;
              })
            }

          }else{
            //无待支付的订单
            this.digitalInfo.bePaidStatus = false;
          }
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取开票金额
    getMoneyInfoFun(res){
      if (res.success) {
        let data = res.result;
        if (data){
          let dataNew = cloneObject(data);
          this.amountColumn.quarterMoney = dataNew.quarterMoney;  //当季开票金额
          this.amountColumn.yearTotalMoney = dataNew.yearBalanceMoney; //年度剩余开票金额
          this.amountColumn.yearMoney = dataNew.yearMoney;  //年度开票金额
          this.amountColumn.quarterLimit = dataNew.quarterMoneyLimit;  //季度最大开票限额
          this.amountColumn.monthMoney = dataNew.monthMoney;  //当月开票金额
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取当前企业服务模式下的月度最大限额
    getMonthLimitFun(res){
      if (res.success) {
        if (res.result){
          let data = res.result.invoiceMax || 0;
          this.amountColumn.monthLimit = data;
        }
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取当季提醒限额
    getQuarterAmountFun(res){
      if (res.success){
        this.amountColumn.inSeasonLimit = res.result;
      }else{
        this.$message.warning(res.message);
      }
    },
    //获取数电最大限额和可开额度
    getPartyListFun(res){
      if (res.success) {
        if (res.result){
          let data = res.result;
          //获取数电相关数据
          if (data.length > 0 && data[0].entDetail){
            let juridicalDate = data[0].entDetail;
            this.digitalInfo.ticketType = juridicalDate.ticketType;  //开票类型 1-传统票 2-数电票 3-混合票
            this.digitalInfo.approvalMethod = juridicalDate.taxMode;  //核定方式 1-查账征收 2-核定征收-双定 3-核定征收-征收率 4-核定征收-应纳税所得率
            this.amountColumn.digitalMonthLimit = juridicalDate.maxSdAmount;  //数电月度最大限额
            this.amountColumn.digitalRemaining = juridicalDate.lastSdAmount;  //数电月度剩余限额
            // this.amountColumn.limitOfHalf = juridicalDate.maxSdAmount21;  //数电限额1/2
            // this.amountColumn.limitOneThird = juridicalDate.maxSdAmount31;  //数电限额1/3
          }
        }
      }else{
        this.$message.warning(res.message);
      }
    },

    //  ---------------------------- 进度条（支付操作） ↓ -----------------------
    //支付
    paymentOther(id){
      let arr = [];
      arr.push(id)
      this.paymentInvoice(arr);
    },
    //支付接口
    paymentInvoice(arr){
      let key = 'paymentInvoice'
      Utils.Storage.set(key,{orderNo: arr});
      // console.log(Utils.Storage.get('paymentInvoice'))
      this.$router.push({
        path: '/myAccount/accountManage',
        query:{
          po:key
        }
      });
    },
    //  ---------------------------- 进度条（发票快递操作） ↓ -----------------------
    //快递
    confirmDelivery(){
      let entId = this.id;
      getConfirmDelivery(entId).then(res => {
        if (res.success) {
          this.$nextTick(()=>{
            this.undoConfig = {
              width: '500px',  //modal宽度
              visible: true,    //modal展示状态
              modalTitle: '',
              title: '',     //标题
              subTitle: '',     //副标题
              content: '发票快递申请成功！我们将开始为您安排寄送，请您耐心等待！',  //内容
              okText: '关闭',    //确定文字
              okType: 'primary',    //确定类型
              cancleText: '',    //取消文字
              cancleType: '',    //取消类型
              source: 3,
            }
          })
        }else{
          this.$message.warning(res.message)
        }
      })
    },
    //下载发票
    invoiceDownload(){
      this.$nextTick(()=>{
        this.downloadFormatInfo.visible = true;
        this.downloadFormatInfo.id = this.detailsData.id;
      })
    },
    //下载
    download(list){
      if (list.length > 0){
        let data = list[0].fileUrl;
        //从链接上截取文件名
        let name = list[0].fileName;

        fetch(data).then((res) => {
          res.blob().then((blob) => {
            const url = window.URL.createObjectURL(blob)
            const a = document.createElement('a')
            a.href = url
            a.download = name;
            a.click()
            window.URL.revokeObjectURL(url)
          })
        })
      }
    },
    //  ---------------------------- 进度条   end ↑ -----------------------


    //  ---------------------------- 查看详情,发票结算信息 ↓ -----------------------
    //查看详情
    getListDetails(bizId,errType){
      let id;
      if (bizId){
        id = bizId;
      }else {
        id = this.$route.query.bizId;
      }

      getTaxInvoiceDetails(id).then(res => {
        if (res.success) {
          if (res.result){
            this.detailsData = res.result;
            this.entId = res.result.entId;
            this.digitalInfo.moneyTotal = res.result.amount;
            let data = cloneObject(res.result);

            //先清空数组 再赋值选中状态追加数据
            let list = [];
            let checkList = data;
            checkList.checkShow = true;
            list = [checkList];
            this.balanceCheckList = list;
            this.overLimitCheckList = list;
            this.balanceCheckNewList = list;


            this.detailsData.amount = conversionElement(data.amount);
            this.detailsData.returnAmountTotal = conversionElement(data.returnAmountTotal);
            //处理开票内容
            for (const key in data.taxContents) {
              this.detailsData.taxContents[key].money = conversionElement(data.taxContents[key].money);
              this.detailsData.taxContents[key].unitPrice = conversionElement(data.taxContents[key].unitPrice);
            }

            //处理首次调用未拿到最终票的状态
            if (errType && this.detailsData.bizStatus == 106){
              //启动定时器
              if (this.timer === null) {
                this.timer = setInterval(() => {
                  this.getListDetails('',true);
                }, 10000);
              }
            }else {
              this.invoiceFailed.invoicePendding = false;
              //销毁定时器
              clearInterval(this.timer);
              this.timer = null;
            }

            //开票状态为120_开票失败 && 判断失败原因errorFlag 1 无错误 2 开票人错误 3 其他错误
            if(data.bizStatus == 120 && data.errorFlag == 2){
              this.invoiceInfo.invoiceUserId = data.invoiceUserId;
              this.getUserManageList();   //获取开票员信息
            }else {
              this.invoiceInfo.invoiceUserId = null;
            }

            this.getListProgress(this.id);

            //处理发票预览
            if (data.invoiceUrl){
              if (data.invoiceUrl.includes('jpeg') || data.invoiceUrl.includes('png') || data.invoiceUrl.includes('jpg')){
                this.isInvoiceType = true;
                this.typeSize = 1;
              }else {
                this.isInvoiceType = false;
              }
            }


            //退票标识展示
            if (this.isInvoiceList.includes(this.detailsData.bizStatus)){
              this.isVisable = true;
              this.typeSize == 1 ? this.isInvoice = true : this.isInvoice = false;
            }

          }
        }else{
          this.$message.warning(res.message);
        }
      })
    },
    //截取长度
    cutstrLength(str, len){
      return cutstr(str, len);
    },
    //申请重开(作废)
    applyReopen(){
      let that = this;
      this.$confirm({
        title: '重开票不能修改部分内容，是否确认？',
        okText: '确认',
        onOk() {
          //跳转申请重开页面携带企业id
          that.$router.push({
            path: '/invoice/applyInvoiceReopen',
            query:{
              bizId: that.detailsData.entId,
              detailsId: that.detailsData.id,
            }
          })
        },
        onCancel() {},
      });
    },
  },
  destroyed() {
    //离开页面是销毁
    clearInterval(this.timer);
    this.timer = null;
  },
}
</script>

<style scoped lang="less">
h3{
  font-weight: bolder;
}
.information_content{
  margin-bottom: 20px;
}

.information_footer{
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;

  .ant-steps{
    width: 100%;
    box-sizing: border-box;
    padding: 20px 30px;
  }

}

.preview{
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  p{
    width: 100%;
    margin-top: 30px;
    margin-bottom: 0;
    font-size: 16px;
    text-align: center;
    color: @color-black;
  }
  .footer{
    width: 100%;
  }
  .img_preview{
    width: 600px;
    height: 300px;
    padding: 20px;
    margin-top: 15px;
    border: 1px dashed #4266E5;
    box-sizing: border-box;
    position: relative;
    img{
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
    //发票作废
    .voidInvoice{
      position: absolute;
      top: 40%;
      left: 30%;

      width: 260px;
      height: 70px;
      font-size: 40px;
      background: rgba(255,255,255,0);
      color: #FF0000;
      letter-spacing: 2px;
      //font-weight: bolder;
      border: 3px solid #ff0000;
      border-radius: 10px;
      transform: rotate(-15deg);
    }
  }
  p:last-child{
    margin-top: 20px;
  }
  .text_preview{
    width: 100%;
    margin-top: 15px;
    position: relative;
    //发票作废
    .voidText{
      color: #FF0000;
      margin-left: 20px;
    }
  }
}


//开票失败
.invoiceFail{
  width: 100%;
  border: 2px dashed #FF0000;
  padding: 5px 20px;
  margin-bottom: 10px;
  /deep/.ant-alert-message{
    color: #FF0000;
  }
  .ant-alert.ant-alert-no-icon{
    width: 400px;
    border-radius: 5px;
  }
  .invoiceFailItem{
    margin: 20px 0;
    p{
      margin-top: 10px;
    }
  }
  .invoiceFailFooter{
    width: 100%;
    margin-top: 20px;
  }
}

//开票中提示
.ant-spin-lg {
  width: 100%;
  height: 150px;
  padding-left: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}
/deep/.ant-spin-text{
  font-size: 24px;
  margin-left: 20px;
}
</style>
